﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TryTM
{
    class Leksem
    {
        static string[] C_PERFECTIVE_GERUND =
        {
            //group1
            "в"
            ,"вши"
            ,"вшись"
            //group2
            ,"ывшись"
            ,"ившись"
            ,"ывши"
            ,"ивши"
            ,"ив"
            ,"ыв"
        };

        static string[] C_ADJECTIVE =
        {
            "ее"
            ,"ие"
            ,"ые"
            ,"ое"
            ,"ими"
            ,"ыми"
            ,"ей"
            ,"ий"
            ,"ый"
            ,"ой"
            ,"ем"
            ,"им"
            ,"ым"
            ,"ом"
            ,"его"
            ,"ого"
            ,"ему"
            ,"ому"
            ,"их"
            ,"ых"
            ,"ую"
            ,"юю"
            ,"ая"
            ,"яя"
            ,"ою"
            ,"ею" 
        };

        static string[] C_PARTICIPLE =
        {
            //group2
            "ивш"
            ,"ывш"
            ,"ующ"
            //group1
            ,"ем"
            ,"нн"
            ,"вш"
            ,"ющ"
            ,"щ"
        };

        static string[] C_REFLEXIVE =
        {
            "ся"
            ,"сь"
        };

        static string[] C_VERB =
        {
            //group2
            "уйте"
            ,"ейте"
            ,"ила"
            ,"ыла"
            ,"ена"
            ,"ите"
            ,"или"
            ,"ыли"
            ,"ило"
            ,"ыло"
            ,"ено"
            ,"ует"
            ,"уют"
            ,"ены"
            ,"ить"
            ,"ыть"
            ,"ишь"
            ,"ей"
            ,"уй"
            ,"ил"
            ,"ыл"
            ,"им"
            ,"ым"
            ,"ен"
            ,"ят"
            ,"ит"
            ,"ыт"
            ,"ую"
            ,"ю"
            //group1
            ,"ла"
            ,"на"
            ,"ете"
            ,"йте"
            ,"ешь"
            ,"нно"
            ,"ли"
            ,"й"
            ,"л"
            ,"ем"
            ,"н"
            ,"ло"
            ,"но"
            ,"ет"
            ,"ют"
            ,"ны"
            ,"ть"
        };

        static string[] C_NOUN =
        {
            "иа"
            ,"ев"
            ,"ов"
            ,"ие"
            ,"ье"
            ,"е"
            ,"иями"
            ,"ями"
            ,"ами"
            ,"еи"
            ,"ии"
            ,"и"
            ,"ией"
            ,"ей"
            ,"ой"
            ,"ий"
            ,"й"
            ,"иям"
            ,"ям"
            ,"ием"
            ,"ем"
            ,"ам"
            ,"ом"
            ,"о"
            ,"у"
            ,"ах"
            ,"иях"
            ,"ях"
            ,"ы"
            ,"ь"
            ,"ию"
            ,"ью"
            ,"ю"
            ,"ия"
            ,"ья"
            ,"я"
            ,"ейш"
            ,"ейше"
            ,"ост"
            ,"ость"
        };

        static string[] C_Aff =
        {
            "ившись"
            ,"ывшись"
            ,"вшись"
            ,"ейте"
            ,"ейше"
            ,"ивши"
            ,"иями"
            ,"ость"
            ,"уйте"
            ,"ывши"
            ,"ами"
            ,"вши"
            ,"его"
            ,"ейш"
            ,"ему"
            ,"ена"
            ,"ено"
            ,"ены"
            ,"ете"
            ,"ешь"
            ,"ивш"
            ,"ией"
            ,"ием"
            ,"ила"
            ,"или"
            ,"ило"
            ,"ими"
            ,"ите"
            ,"ить"
            ,"ишь"
            ,"иям"
            ,"иях"
            ,"йте"
            ,"нно"
            ,"ого"
            ,"ому"
            ,"ост"
            ,"ует"
            ,"уют"
            ,"ующ"
            ,"ывш"
            ,"ыла"
            ,"ыли"
            ,"ыло"
            ,"ыми"
            ,"ыть"
            ,"ями"
            ,"ам"
            ,"ах"
            ,"ая"
            ,"вш"
            ,"ев"
            ,"ее"
            ,"еи"
            ,"ей"
            ,"ем"
            ,"ем"
            ,"ен"
            ,"ет"
            ,"ею"
            ,"иа"
            ,"ив"
            ,"ие"
            ,"ии"
            ,"ий"
            ,"ил"
            ,"им"
            ,"ит"
            ,"их"
            ,"ию"
            ,"ия"
            ,"ла"
            ,"ли"
            ,"ло"
            ,"на"
            ,"нн"
            ,"но"
            ,"ны"
            ,"ов"
            ,"ое"
            ,"ой"
            ,"ом"
            ,"ою"
            ,"ть"
            ,"уй"
            ,"ую"
            ,"ыв"
            ,"ые"
            ,"ый"
            ,"ыл"
            ,"ым"
            ,"ыт"
            ,"ых"
            ,"ье"
            ,"ью"
            ,"ья"
            ,"ют"
            ,"ющ"
            ,"юю"
            ,"ям"
            ,"ят"
            ,"ях"
            ,"яя"
            ,"в"
            ,"е"
            ,"и"
            ,"й"
            ,"л"
            ,"н"
            ,"о"
            ,"у"
            ,"щ"
            ,"ы"
            ,"ь"
            ,"ю"
            ,"я"
        };

        public static string GetStem(string p_word)
        {
            p_word = p_word.Trim();
            for (int i = 0; i < C_Aff.Length; i++)
            {
                if (p_word.Length > C_Aff[i].Length)
                    if (p_word.LastIndexOf(C_Aff[i]) == p_word.Length - C_Aff[i].Length)
                        return p_word.Substring(0, p_word.LastIndexOf(C_Aff[i]));
            }
            return p_word;
        }
    }
}

